#include "net/EventLoop.h"
#include "Base/Logger.h"
#include "Base/Timestamp.h"
#include "Base/CurrectThread.h"
#include <time.h>
#include <thread>
using namespace toym;
using namespace toym::net;

EventLoop* g_loop;

void func(int i) {
    LOG_INFO << CurrectThread::getTidStr() << " " << i;
}

void threadFunc() {
    time_t now = ::time(NULL);
    for (int i = 0; i < 10; ++i) {
        g_loop->runAt(
            Timestamp::second(now+i+1),
            [i]() {
                func(i);
            }
        );
    }
}

int main() {
    EventLoop loop;
    g_loop = &loop;
    // loop.runAt(Timestamp::second(now+1L), func);
    std::thread t(threadFunc);
    threadFunc();
    loop.loop();
}